Handle JsonSchemaRequestException as 400 Bad Request in ThrowableHandler - #189
Conversation
Raise the minimum bear/resource requirement to ^1.33 which introduces JsonSchemaRequestException / JsonSchemaResponseException. In ThrowableHandler, normalise JsonSchemaRequestException into BadRequestException (code 400) so VndError emits the correct 4xx status instead of falling through to 500. JsonSchemaResponseException (server-side schema mismatch) is unchanged and continues to produce a 500. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review. 📝 WalkthroughWalkthroughThe PR upgrades ChangesJSON schema error handling
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This PR changes schema request failures to return 400 responses while preserving 500 responses for schema response failures; no actionable merge-blocking risk remains after normal checks and review. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 1.x #189 +/- ##
===========================================
Coverage 100.00% 100.00%
- Complexity 52 53 +1
===========================================
Files 18 18
Lines 131 125 -6
===========================================
- Hits 131 125 -6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
Summary
bear/resourcerequirement from^1.16to^1.33ThrowableHandler::handle(), convertJsonSchemaRequestExceptiontoBadRequestException, preserving its 4xx code, soVndErroremits the correct 4xx response instead of the generic 500JsonSchemaResponseException(server-side schema mismatch) continues to produce a 500 — no change neededTest plan
testJsonSchemaRequestException→ 400 withapplication/vnd.error+jsontestJsonSchemaRequestExceptionWithCustomCode→ preserves a non-default 4xx code (403) withapplication/vnd.error+jsontestJsonSchemaResponseException→ 500 withapplication/vnd.error+jsontestException(404) andtestError(PHP Error → 500) still pass